/**
 * Created by luqidong on 2017/12/20.
 */
import axios from './http';
import {NEWS_URI,MASTER_URI,USER_URI} from '../uitls/ajaxUrl';
/**
 * Created by luqidong on 2017/12/15.
 */
/**
 * 申请彩帝
 * @param token
 * @param page
 * @returns {*}
 */
export function getHomeRecommedR({token, page = 1}) {
    if(token) {
        return axios.get(`${MASTER_URI}/ml/plan/byFresh?page=${page}&pageSize=20`, {
            headers: {
                token
            }
        })
    }
    return axios.get(`${MASTER_URI}/ml/plan/byFresh?page=${page}&pageSize=20`);
}
/**
 * 登录
 * @param username
 * @param userpwd
 * @returns {*}
 */
export function loginR(username, userpwd) {
    return axios.post(`${MASTER_URI}/ml/mbr/701`, {
        "UserName": username, "Password": userpwd
    });
}


/**
 * 注册验证码
 * @param phone
 */
export function registersimR(phone) {
    return axios.get(`${USER_URI}/Handler.ashx?action=704&params={"Mobile":"${phone}","TypeID":"1"}`, {
        headers: {
            appcode: 2
        }
    });
}

export function registerR({phone, yzm, pwd, ucode}) {
    return axios.post(`${MASTER_URI}/ml/mbr/703`, {
        "RandomGuid": ucode,
        "UserName": phone,
        "Password": pwd,
        "ValidCode": yzm
    }, {
        headers: {
            appCode: '3',
            channel: 'td',
            devicecode: "",
            devicetype: 'h5',
            version: ''
        }
    });
}

/**
 * 首页轮播
 */
export function getsilderR() {
    return axios.get(`${NEWS_URI}/banner`, {
        headers: {
            appCode: 92
        }
    });
}
/**
 * 获取新闻
 * @param id
 * @returns {*}
 */
export function getnewsinfoR(id) {
    return axios.get(`${NEWS_URI}/news/${id}`, {
        headers: {
            appCode: 92
        }
    });
}